<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>用户界面</title>
    <link rel="shortcut icon" th:href="@{/logo/favicon.ico}"/>
    <!-- Custom fonts for this template-->
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/fontawesome-free/css/all.min.css}"/>
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
          rel="stylesheet">
    <!-- Custom styles for this template-->
    <link rel="stylesheet" type="text/css" th:href="@{/css/sb-admin-2.min.css}"/>

    <!-- Custom styles for this page -->
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/dataTables.bootstrap4.min.css}"/>


</head>
<style>
    td button {
        margin-right: 8px;
        width: 40px;
    }
    div img {
        width: 50%;
    }
    .table th, .table td {
        text-align: center;
        vertical-align: middle !important;
    }
</style>
<body id="page-top">

<!-- Page Wrapper -->
<div id="wrapper">
    <!-- Sidebar -->
    <div th:if="${role} == 2" style="height: auto;background-color: #224abe;">
        <div  th:replace="commons/admin_sidebar::#accordionSidebar" ></div>
    </div>
    <div th:if="${role} == 4" style="height: auto;background-color: #224abe;">
        <div th:replace="commons/aduit_sidebar::#accordionSidebar"></div>
    </div>
    <div th:if="${role} == 3" style="height: auto;background-color: #224abe;">
        <div th:replace="commons/aduit_sidebar::#accordionSidebar"></div>
    </div>

    <!-- End of Sidebar -->
    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">
        <!-- Main Content -->
        <div id="content">
            <div th:replace="commons/admin_navbar::#navbar"></div>
            <div th:replace="commons/modify_report_modal2::#report2_modal"></div>
            <!-- Begin Page Content -->
            <div class="container-fluid">
                <!-- DataTales Example -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <select class="chosen-select entrust_content form-control"
                                id="holder"
                                data-placeholder="Choose a State...">
                            <option th:each="holder:${holders}"
                                    th:value="${holder?.userId}">
                                [[${holder?.holder}]]
                            </option>
                        </select>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-hover text-nowrap" id="dataTable" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>报告id</th>
                                    <th>报告编号</th>
                                    <th>委托单位</th>
                                    <th>检测日期</th>
                                    <th>提交时间</th>
                                    <th>审核员</th>
                                    <th>状态</th>
                                    <th>下载次数</th>
                                    <th>下载</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- End of Main Content -->
        <!-- Footer -->
        <div th:replace="commons/footer::#footer"></div>
        <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

</div>
<!-- End of Page Wrapper -->

<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
</a>

<!-- Logout Modal-->
<div th:replace="commons/logout::#logoutModal"></div>

<!-- Bootstrap core JavaScript-->
<script type="text/javascript" th:src="@{/vendor/jquery/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>

<script type="text/javascript" th:src="@{/js/admin_commons.js}"></script>
<!-- Core plugin JavaScript-->
<script type="text/javascript" th:src="@{/vendor/jquery-easing/jquery.easing.min.js}"></script>
<!-- Custom scripts for all pages-->

<script type="text/javascript" th:src="@{/js/sb-admin-2.min.js}"></script>

<!-- Page level plugins -->
<script type="text/javascript" th:src="@{/vendor/datatables/jquery.dataTables.min.js}"></script>
<script type="text/javascript" th:src="@{/vendor/datatables/dataTables.bootstrap4.min.js}"></script>

<script type="text/javascript" th:src="@{/js/demo/datatables-demo.js}"></script>
<script type="text/javascript" th:src="@{/js/admin_print_report2.js}"></script>
<!--modal数据装载js modal提交修改-->
<script type="text/javascript" th:src="@{/js/report_modal.js}"></script>
</body>
<script>
    $("#holder").change(function () {
        if ($(this).val() != 0) {
            load_datatable_print("/admin/view-holder2?status=4&hid=" + $(this).val());
        } else {
            load_datatable_print("/admin/view-all2?status=4");
        }
    });
    $(function () {
        load_datatable_print("/admin/view-all2?status=4");
    })
</script>
<script>
    function view_report2(rid,status) {
        if("[[${modify_token}]]" != "" && "[[${modify_token}]]" == "true"){
            window.open("/user/get-save-report2?rid="+rid+"&status="+status+"&ten="+localStorage.getItem("token"));
            return false;
        }
        $.ajax({
            type: "GET",
            url: "/user/get2?rid=" + rid,
            success: function (data) {
                var obj = data.data;
                console.log(obj.entrustingParty);
                $("#report2Id").val(obj.report2Id);
                $("#reportNumber").val(obj.reportNumber);
                $("#projectName").val(obj.projectName);
                $("#entrustingParty").val(obj.entrustingParty);
                $(".entrustingParty").text(obj.entrustingParty);
                $("#checkCategory").val(obj.checkCategory);
                $("#reportDate").val(obj.reportDate);
                $("#checkOrganization").text(obj.checkOrganization);  //text
                $("#checkItem").text(obj.checkItem);
                $("#basisStandard").text(obj.basisStandard);
                $("#basisNumber").text(obj.basisNumber);
                $("#checkAddress").val(obj.checkAddress);
                $("#checkMethod").val(obj.checkMethod);
                $("#equipmentName").val(obj.equipmentName);
                $("#equipmentModel").val(obj.equipmentModel);
                $("#equipmentMeasurementCertificate").val(obj.equipmentMeasurementCertificate);
                $("#machineName").val(obj.machineName);
                $("#machineModel").val(obj.machineModel);
                $("#serialNumber").val(obj.serialNumber);
                $("#hbNumber").val(obj.hbNumber);
                $("#machineProtectionNumber").val(obj.machineProtectionNumber);
                $("#equipmentNumber").val(obj.equipmentNumber);
                $("#emissionPeriod").val(obj.emissionPeriod);
                $("#machineDate").val(obj.machineDate);
                $("#machineVin").val(obj.machineVin);
                $("#machineManufacturer").val(obj.machineManufacturer);
                $("#engineModel").val(obj.engineModel);
                $("#engineNumber").val(obj.engineNumber);
                $("#engineManufacturer").val(obj.engineManufacturer);
                $("#engineReprocessType").val(obj.engineReprocessType);
                $("#engineSpeed").val(obj.engineSpeed);
                $("#enginePower").val(obj.enginePower);
                $("#enviProtNo").val(obj.enviProtNo);
                $("#engineApprovalNumber").val(obj.engineApprovalNumber);
                $("#agentName").val(obj.agentName);
                $("#agentMobile").val(obj.agentMobile);
                $("#agentAddress").val(obj.agentAddress);
                $("#temperature").val(obj.temperature);
                $("#pressure").val(obj.pressure);
                $("#humidity").val(obj.humidity);
                $("#elevation").val(obj.elevation);
                $("#checkDate").val(obj.checkDate);
                $(".checkDate").text(obj.checkDate);
                $("#checkStartEndTime").val(obj.checkStartEndTime);
                $("#checkAvg").val(obj.checkAvg);
                $("#checkSpeed").val(obj.checkSpeed);
                $("#checkHighArea").val(obj.checkHighArea);
                $("#checkLimit").val(obj.checkLimit);
                $("#checkResult1").val(obj.checkResult1);
                $("#checkResult2").val(obj.checkResult2);
                $("#checkResult3").val(obj.checkResult3);
                $("#checkVp").val(obj.checkVp);
                $("#checkJudgment").val(obj.checkJudgment);
                $("#pic1").attr("src", obj.pic1);
                $("#pic2").attr("src", obj.pic2);
                $("#pic3").attr("src", obj.pic3);
                $("#pic4").attr("src", obj.pic4);
                $("#pic5").attr("src", obj.pic5);
                $("#pic6").attr("src", obj.pic6);
                $("#pic7").attr("src", obj.pic7);
                $("#pic8").attr("src", obj.pic8);
                $("#pic9").attr("src", obj.pic9);
                $("#pic10").attr("src", obj.pic10);
            }
        });
        $("#report2_modal").modal("show");
    }

    //数据写入时变化
    $("#reportNumber").bind("input propertychange", function () {
        $(".report_number").html($(this).val());
    });
    $("#entrustingParty").bind("input propertychange", function () {
        $(".entrustingParty").html($(this).val());
    });
    $("#checkDate").bind("input propertychange", function () {
        $(".checkDate").html($(this).val());
    });

    //页码变化 , 内容切换
    var count = 1;
    $(".pagination li").eq(0).click(function () {
        if (count <= 1) {
            $(".pagination li").eq(0).addClass("disabled");
            return false;
        } else {
            $(".pagination li").eq(6).removeClass("disabled");
            $(".pagination li").eq(count).removeClass("active");
            $("#content_" + count).css("display", "none");
            --count;
            $(".pagination li").eq(count).addClass("active");
            $("#content_" + count).css("display", "block");
        }
        if (count == 1) {
            $(".pagination li").eq(0).addClass("disabled");
        }
    });
    $(".pagination li").eq(6).click(function () {
        if (count >= 5) {
            $(".pagination li").eq(6).addClass("disabled");
            return false;
        }
        $(".pagination li").eq(0).removeClass("disabled");
        $(".pagination li").eq(count).removeClass("active");
        $("#content_" + count).css("display", "none");
        ++count;
        $(".pagination li").eq(count).addClass("active");
        $("#content_" + count).css("display", "block");
        if (count == 5) {
            $(".pagination li").eq(6).addClass("disabled");
        }
    })
    $(".pagination li").eq(1).click(function () {
        $(".pagination li").eq(6).removeClass("disabled");
        $(".pagination li").eq(0).addClass("disabled");
        $(".pagination li").eq(1).addClass("active");
        $(".pagination li").eq(count).removeClass("active");
        $("#content_" + count).css("display", "none");
        $("#content_" + 1).css("display", "block");
        count = 1;
    });
    $(".pagination li").eq(5).click(function () {
        $(".pagination li").eq(0).removeClass("disabled");
        $(".pagination li").eq(6).addClass("disabled");
        $(".pagination li").eq(5).addClass("active");
        $(".pagination li").eq(count).removeClass("active");
        $("#content_" + count).css("display", "none");
        $("#content_" + 5).css("display", "block");
        count = 5;
    });
    $(".pagination li").eq(2).click(function () {
        $(".pagination li").eq(0).removeClass("disabled");
        $(".pagination li").eq(6).removeClass("disabled");
        $(".pagination li").eq(count).removeClass("active");
        $(".pagination li").eq(2).addClass("active");
        $("#content_" + count).css("display", "none");
        $("#content_" + 2).css("display", "block");
        count = 2;
    });
    $(".pagination li").eq(3).click(function () {
        $(".pagination li").eq(0).removeClass("disabled");
        $(".pagination li").eq(6).removeClass("disabled");
        $(".pagination li").eq(count).removeClass("active");
        $(".pagination li").eq(3).addClass("active");
        $("#content_" + count).css("display", "none");
        $("#content_" + 3).css("display", "block");
        count = 3;
    });
    $(".pagination li").eq(4).click(function () {
        $(".pagination li").eq(0).removeClass("disabled");
        $(".pagination li").eq(6).removeClass("disabled");
        $(".pagination li").eq(count).removeClass("active");
        $(".pagination li").eq(4).addClass("active");
        $("#content_" + count).css("display", "none");
        $("#content_" + 4).css("display", "block");
        count = 4;
    });


    $("#modify_report2").click(function () {
        var data = JSON.stringify({
            report2Id :$("#report2Id").val().trim(),
            reportNumber: $("#reportNumber").val().trim(),
            projectName: $("#projectName").val().trim(),
            entrustingParty: $("#entrustingParty").val().trim(),
            checkCategory: $("#checkCategory").val().trim(),
            reportDate: $("#reportDate").val().trim(),
            checkOrganization: $("#checkOrganization").text().trim(),  //text
            checkItem: $("#checkItem").text().trim(),
            basisStandard: $("#basisStandard").text().trim(),
            basisNumber: $("#basisNumber").text().trim(),
            checkAddress: $("#checkAddress").val().trim(),
            checkMethod: $("#checkMethod").val().trim(),
            equipmentName: $("#equipmentName").val().trim(),
            equipmentModel: $("#equipmentModel").val().trim(),
            equipmentMeasurementCertificate: $("#equipmentMeasurementCertificate").val().trim(),
            machineName: $("#machineName").val().trim(),
            machineModel: $("#machineModel").val().trim(),
            serialNumber: $("#serialNumber").val().trim(),
            hbNumber: $("#hbNumber").val().trim(),
            machineProtectionNumber: $("#machineProtectionNumber").val().trim(),
            equipmentNumber: $("#equipmentNumber").val().trim(),
            emissionPeriod: $("#emissionPeriod").val().trim(),
            machineDate: $("#machineDate").val().trim(),
            machineVin: $("#machineVin").val().trim(),
            machineManufacturer: $("#machineManufacturer").val().trim(),
            engineModel: $("#engineModel").val().trim(),
            engineNumber: $("#engineNumber").val().trim(),
            engineManufacturer: $("#engineManufacturer").val().trim(),
            engineReprocessType: $("#engineReprocessType").val().trim(),
            engineSpeed: $("#engineSpeed").val().trim(),
            enginePower: $("#enginePower").val().trim(),
            enviProtNo: $("#enviProtNo").val().trim(),
            engineApprovalNumber: $("#engineApprovalNumber").val().trim(),
            agentName: $("#agentName").val().trim(),
            agentMobile: $("#agentMobile").val().trim(),
            agentAddress: $("#agentAddress").val().trim(),
            temperature: $("#temperature").val().trim(),
            pressure: $("#pressure").val().trim(),
            humidity: $("#humidity").val().trim(),
            elevation: $("#elevation").val().trim(),
            checkDate: $("#checkDate").val().trim(),
            checkStartEndTime: $("#checkStartEndTime").val().trim(),
            checkAvg: $("#checkAvg").val().trim(),
            checkSpeed: $("#checkSpeed").val().trim(),
            checkHighArea: $("#checkHighArea").val().trim(),
            checkLimit: $("#checkLimit").val().trim(),
            checkResult1: $("#checkResult1").val().trim(),
            checkResult2: $("#checkResult2").val().trim(),
            checkResult3: $("#checkResult3").val().trim(),
            checkVp: $("#checkVp").val().trim(),
            checkJudgment: $("#checkJudgment").val().trim()
        });
        $.ajax({
            url: "/admin/modify-report2",
            type: "post",
            contentType: "application/json;charset=utf-8",
            beforeSend: function (request) {
                request.setRequestHeader("uid", localStorage.getItem("token"));
            },
            data:data,
            success:function (result) {
                alert(result.message);
                $("#dataTable").DataTable().ajax.reload();
            }
        });

    })
</script>
</html>
